package lyo.levelup.swing.classwork;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.net.InetAddress;
import javax.swing.JPanel;

public class textPanel extends JPanel
{        
    @Override
    public void paintComponent(Graphics grphcs)
    {
        super.paintComponent(grphcs);
        Graphics2D gr2D = (Graphics2D) grphcs;
        gr2D.setColor(Color.red);
        Font f = new Font(Font.SERIF, Font.BOLD, 18);
        gr2D.setFont(f);
        gr2D.drawString("My IP is:\n"+this.getIP(), 10, 20);
    }
    private String getIP()
    {
        String IP = "";
      try {
       IP = InetAddress.getLocalHost().getHostAddress();
      }
      catch (Exception e) {
       IP = "Error finding IP";
      }
      return IP;
    }
}